package com.benshou.bsoa.controller.dingding;

;
import com.benshou.bsoa.common.dto.ResponseVo;
import com.benshou.bsoa.utils.CreateAccessTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/dingding")
public class GetAccessTokenController {

    @Autowired
    private CreateAccessTokenUtil createAccessTokenUtil;

    /*
     * 获取钉钉的access_token
     */
    @GetMapping("/getAccessToken")
    public ResponseVo<String> getAccessToken() {
        try {
            String accessToken = createAccessTokenUtil.getToken();
            return ResponseVo.success(accessToken);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseVo.fail("获取access_token失败");
        }
    }
}
